package com.m7.imkfsdk.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.inmotion.android.sdk.moor7.Constant;
import com.moor.imkf.IMChatManager;

public class NewMsgReceiver extends BroadcastReceiver {
    private static final String TAG = "NewMsgReceiver";

    public NewMsgReceiver() {
    }

    public void onReceive(Context context, Intent intent) {

        Log.d(TAG, "onReceive, action: " + intent.getAction() +
                ", component pkg: " + intent.getComponent().getPackageName() +
                ", component class name" + intent.getComponent().getClassName() +
                ", extra: " + (intent.getExtras() == null ? "null" : intent.getExtras().toString()));
        if (intent.getAction().equals(IMChatManager.NEW_MSG_ACTION)) {
            Intent msgIntent = new Intent(Constant.ACTION_RECEIVED_NEW_MSG);
            msgIntent.setPackage(context.getPackageName());
            context.sendBroadcast(msgIntent);
            Log.d(TAG, "send new msg broadcast");
        }
    }
}
